package 字符串.反转字符串;

/**
 * @author: wh(1835734390 @ qq.com)
 * @date: 2023/1/16 15:24
 * @description:
 * @version:
 */
public class Solution {
    public static void main(String[] args) {
        String s = "hello";
        reverseString(s.toCharArray());
    }

    //不要给另外的数组分配额外的空间，你必须原地修改输入数组、使用 O(1) 的额外空间解决这一问题
    public static void reverseString(char[] s) {
        int length = s.length;
        int left = 0;
        int right = length - 1;
        while (left < right){
            char tem = s[left];
            s[left] = s[right];
            s[right] = tem;
            left++;
            right--;
        }
        System.out.println("反转结束");
    }
}
